<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>Examples</title>
  <meta name="description" content="">
  <meta name="keywords" content="">

  <link rel="stylesheet" href="lib/swiper/css/swiper.css">
  <script src="lib/swiper/js/swiper.js"></script>

  <style>
    .swiper-container {
      width: 600px;
      height: 300px;
    }

    .swiper-slide img {
      width: 100%;
    }
  </style>
</head>

<body>
  <div class="swiper-container a">

    <div class="swiper-wrapper">
      <!-- <div class="swiper-slide">
        <img src="./imgs/1.jpg" alt="">
      </div> -->
    </div>

    <!-- 如果需要分页器 -->
    <div class="swiper-pagination"></div>
  </div>

  <script>
    const imgs = [
      "./imgs/1.jpg",
      "./imgs/2.jpg",
      "./imgs/3.jpg",
    ]

    setTimeout(() => {
      document.querySelector(".swiper-wrapper").innerHTML = imgs.map(
        (item) => {
          return `<div class="swiper-slide">
        <img src="${item}" alt="">
      </div>`
        }
      ).join("")

      /* 初识化Swiper对象的实际必须在dom渲染完毕之后 */
      new Swiper(".a",
      {
        // 如果需要分页器
        pagination: {
          el: '.swiper-pagination',
        },
      }
    )
    }, 2000)

    // new Swiper(".a",
    //   {
    //     // 如果需要分页器
    //     pagination: {
    //       el: '.swiper-pagination',
    //     },
    //   }
    // )
  </script>
</body>

</html>